LinkedForwardStar Link[MAXM]; int Head[MAXN]= {0}; int size = 1;
voidInsert(int u, int v){ Link[++ size].to = v; Link[size].next = Head[u];
Head[u] = size; }
int N, M, K; int st, ed;
structMatrix { LL a[MAXM][MAXM];
voidinit(){ for (int i = 1; i <= size; i ++) for (int j = 1; j <= size; j ++) a[i][j] = 0; } Matrix operator * (const Matrix& p) const { Matrix newmat; newmat.init (); for (int i = 1; i <= size; i ++) for (int j = 1; j <= size; j ++) for (int k = 1; k <= size; k ++) newmat.a[i][j] = (newmat.a[i][j] + a[i][k] * p.a[k][j] % MOD) % MOD; return newmat; } } ; Matrix mats, bem;
LL power(int p){ while (p) { if (p & 1) mats = mats * bem; bem = bem * bem; p >>= 1; } LL ans = 0; for (int i = Head[ed]; i; i = Link[i].next) ans = (ans + mats.a[1][i ^ 1]) % MOD; return ans; }
intgetnum(){ int num = 0; char ch = getchar ();
while (! isdigit (ch)) ch = getchar (); while (isdigit (ch)) num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();
return num; }
intmain(){ N = getnum (), M = getnum (), K = getnum (), st = getnum () + 1, ed = getnum () + 1; for (int i = 1; i <= M; i ++) { int u = getnum () + 1, v = getnum () + 1; Insert (u, v), Insert (v, u); } for (int i = Head[st]; i; i = Link[i].next) bem.a[1][i] = 1; for (int i = 2; i <= size; i ++) { int v = Link[i].to; for (int j = Head[v]; j; j = Link[j].next) { if ((j ^ 1) == i) continue; bem.a[i][j] = 1; } } for (int i = 1; i <= size; i ++) mats.a[i][i] = 1; LL ans = power (K); cout << ans << endl;